import math

import pyautogui
from position import Position


# 传入两个坐标判断第一个坐标，在第二个坐标的什么位置， ，
def get_orientation(position_one, position_two):
    # 1 是 上左  2 上右  3 右下  4 下左
    if position_two.x < position_one.x and position_two.y < position_one.y:
        return '上左'
    elif position_two.x > position_one.x and position_two.y < position_one.y:
        return '上右'
    elif position_two.x > position_one.x and position_two.y > position_one.y:
        return '右下'
    elif position_two.x < position_one.x and position_two.y > position_one.y:
        return '下左'


# 判断敌人在左边还是右边
def get_left_or_right(Zhu_Jue, Di_ren):
    if Zhu_Jue.x > Di_ren.x:
        return "右"
    else:
        return "左"


# 计算两个点的距离
def ji_Position_Ju_li(position_one, position_two):
    return int(
        math.sqrt(math.pow((position_one.x - position_two.y), 2) + math.pow((position_one.y - position_two.y), 2)))


# 角色攻击
def fire():
    pyautogui.press('j')
    pyautogui.keyDown('k')
    pyautogui.press('i')
    pyautogui.press('l')
    pyautogui.press('e')
    pyautogui.press('r')
    pyautogui.press('space')


def get_x_y(i):
    x = int(int(i.xywh.cpu().numpy().tolist()[0][0]))
    y = int(int(i.xywh.cpu().numpy().tolist()[0][1]))
    return Position(x, y)
